#!/bin/sh
# PCP QA Test No. 1138
# Check various tools correctly fail with a corrupted archive
# See GH#475 libpcp SEGV on corrupt archive
#
# Copyright (c) 2018 Red Hat.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.python

$python -c "from pcp import pmapi" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "python pcp pmapi module not installed"

which pmrep >/dev/null 2>&1 || _notrun "pmrep not installed"

_cleanup()
{
    cd $here
    $sudo rm -rf $tmp $tmp.*
}

status=1	# failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

#
# input archive has corrupted labelset metadata

echo Expect all of these to fail with PM_ERR_LOGREC
pmdumplog badarchives/corrupted_labelset && exit
pminfo -fl -a badarchives/corrupted_labelset && exit
pmrep -a badarchives/corrupted_labelset disk.dev.read && exit

# success, all done
status=0
exit
